import requests
import json
class FeishuTalk:

    # 机器人webhook
    chatGPT_url = 'https://open.feishu.cn/open-apis/bot/v2/hook/164ee6b8-93f7-480e-81d2-f86601af1458'

    # 发送文本消息
    def sendTextmessage(self, content):
        url = self.chatGPT_url
        headers = {
            "Content-Type": "application/json; charset=utf-8",
        }
        payload_message = {
            "msg_type": "text",
            "content": {
            	# @ 单个用户 <at user_id="ou_xxx">名字</at>
                "text": content + "<at user_id=\"all\">test</at>"  
                # @ 所有人 <at user_id="all">所有人</at>
                # "text": content + "<at user_id=\"all\">test</at>"
            }
        }
        response = requests.post(url=url, data=json.dumps(payload_message), headers=headers)
        return response.json
    
 # 执行发送文本消息
content = "测试！"
FeishuTalk().sendTextmessage(content)